#include "Config.h"

/*Config::Config(void)
{
}

Config::~Config(void)
{
}*/

unsigned int Config::FPS = 60;
unsigned int Config::WIDTH = 800;
unsigned int Config::HEIGHT = 600;
double Config::DELTA_TIME =  1000/FPS;
double Config::PHYSIC_SCALE = 8;//6
double Config::PHYSIC_STEP = DELTA_TIME / 1000;
unsigned int Config::VEL_ITERATIONS = 6;
unsigned int Config::POS_ITERATIONS = 2;

unsigned int Config::FIRST_LVL = 1;
bool Config::LOAD_GRAPHIC = 1;
unsigned int Config::DETAILS_LVL = 3;
bool Config::DEV_MODE = 1;

void Config::getCfg()
{
	FILE *f;
	fopen_s(&f, "dane/arkanoid.cfg", "r");

	unsigned int t1, t2;
	
	fscanf_s(f, "%i\n%i\n%i\n%i\n%i\n%i\n%i", &Config::FPS, &Config::WIDTH, &Config::HEIGHT, &Config::FIRST_LVL, &t1, &Config::DETAILS_LVL, &t2);
	//fscanf_s(f, "%i\n%i\n%i\n%i\n%i\n%i", &Config::FPS, &Config::WIDTH, &Config::HEIGHT, &Config::FIRST_LVL, &Config::LOAD_GRAPHIC, &Config::DETAILS_LVL);
	Config::LOAD_GRAPHIC = t1;
	Config::DEV_MODE = t2;
	fclose(f);

	Config::DELTA_TIME = (1.0 / Config::FPS);
}

void Config::flushCfg()
{
	FILE *f;
	fopen_s(&f, "dane/arkanoid.cfg", "w");
	fprintf_s(f, "%i\n%i\n%i\n%i\n%i\n%i\n%i\n", Config::FPS, Config::WIDTH, Config::HEIGHT, Config::FIRST_LVL, Config::LOAD_GRAPHIC, Config::DETAILS_LVL, Config::DEV_MODE);
	fclose(f);
}
